package com.gm.baseplatform.base;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gm.baseplatform.base.module.Module;

public class BasePortalServlet extends HttpServlet {

	private static final long serialVersionUID = -4171030587616082823L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		ServletContext servletContext = getServletContext();
		ResourceCachePool resourceCachePool = 
			(ResourceCachePool)servletContext.getAttribute("resourceCachePool");
		Map<Module,List<?>> moduleTree = resourceCachePool.getModuleTreeCache();
		request.setAttribute("moduleTree", moduleTree);
		request.getRequestDispatcher("/base/index.jsp").forward(request, response);
	}

}
